﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Profile;

namespace WebSite.admin.system
{
    public partial class shop_config02 : BaseAdmin
    {
       

        // Methods
        private void Bind()
        {
            string sql = "select top 1 * from DB_Shopconfig where isnull(shopid,0)=" + base.AdminShopId;
            DataTable table = new DataTable();
            table = SQLAccess.GreatDs(sql).Tables[0];
            this.shopicp1.Value = table.Rows[0]["shopicp1"].ToString();
            this.shopicp2.Text = table.Rows[0]["shopicp2"].ToString();
            this.shopwaterfile.Text = table.Rows[0]["shopwaterfile"].ToString();
            this.shopwater1.SelectedValue = table.Rows[0]["shopwater1"].ToString();
            this.shopwater2.Value = table.Rows[0]["shopwater2"].ToString();
            this.shopku.SelectedValue = table.Rows[0]["shopku"].ToString();
            this.shopmoku.Value = table.Rows[0]["shopmoku"].ToString();
            this.cardhead.Value = table.Rows[0]["cardhead"].ToString();
            this.shoppricebi.Value = table.Rows[0]["shoppricebi"].ToString();
            this.shopscore1.Value = table.Rows[0]["shopscore1"].ToString();
            this.shopscore2.Value = table.Rows[0]["shopscore2"].ToString();
            this.shopscore3.Value = table.Rows[0]["shopscore3"].ToString();
            this.shophou.Value = table.Rows[0]["shophou"].ToString();
            this.shopisfig.SelectedValue = table.Rows[0]["shopisfig"].ToString();
            this.shopmopic.Text = table.Rows[0]["shopmopic"].ToString();
            this.shophang.Value = table.Rows[0]["shophang"].ToString();
            this.shopmemberscore.Value = table.Rows[0]["shopmemberscore"].ToString();
            this.shoptntime.SelectedValue = table.Rows[0]["shoptntime"].ToString();
            this.shopmoarea.Value = table.Rows[0]["shopmoarea"].ToString();
            this.shopupfile.Value = table.Rows[0]["shopupfile"].ToString();
            this.shopiswu.SelectedValue = table.Rows[0]["shopiswu"].ToString();
            this.shopproping.SelectedValue = table.Rows[0]["shopiswu"].ToString();
            this.shopisorder.SelectedValue = table.Rows[0]["shopisorder"].ToString();
            this.shopprocolor.Value = table.Rows[0]["shopprocolor"].ToString();
            this.shopisflower.SelectedValue = table.Rows[0]["shopisflower"].ToString();
            this.shopisflower1.SelectedValue = table.Rows[0]["shopisflower1"].ToString();
            this.shopmessage.Text = table.Rows[0]["shopmessage"].ToString();
            this.istotal1.Checked = (bool)table.Rows[0]["istotal1"];
            this.istotal2.Checked = (bool)table.Rows[0]["istotal2"];
            this.total1.Text = table.Rows[0]["total1"].ToString();
            this.total2.Text = table.Rows[0]["total2"].ToString();
            this.istotalpic.Checked = (bool)table.Rows[0]["istotalpic"];
            this.flash.Text = table.Rows[0]["flashfile"].ToString();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            upload upload = new upload();
            string str = upload.Up(this.file1, "../../uploadfile/banner/");
            base.Response.Write(upload.Resup[Convert.ToInt32(str)]);
            this.shopicp2.Text = upload.s;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            upload upload = new upload();
            string str = upload.Up(this.file2, "../../uploadfile/banner/");
            base.Response.Write(upload.Resup[Convert.ToInt32(str)]);
            this.shopwaterfile.Text = upload.s;
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            upload upload = new upload();
            string str = upload.Up(this.file3, "../../uploadfile/banner/");
            base.Response.Write(upload.Resup[Convert.ToInt32(str)]);
            this.shopmopic.Text = upload.s;
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            upload upload = new upload();
            string str = upload.Up(this.flashfile, "../../uploadfile/banner/");
            base.Response.Write(upload.Resup[Convert.ToInt32(str)]);
            this.flash.Text = upload.s;
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            SQLAccess.DoSql(string.Concat(new object[] { 
            "update DB_Shopconfig set shopicp1='", re.replace(this.shopicp1.Value), "',shopicp2='", re.replace(this.shopicp2.Text), "',shopwaterfile='", re.replace(this.shopwaterfile.Text), "',shopwater1=", re.replace(this.shopwater1.SelectedValue), ",shopisflower=", this.shopisflower.SelectedValue, ",shopmessage='", this.shopmessage.Text, "',shopwater2=", re.replace(this.shopwater2.Value), ",shopku=", re.replace(this.shopku.SelectedValue), 
            ",shopmoku=", re.replace(this.shopmoku.Value), ",shoppricebi=", re.replace(this.shoppricebi.Value), ",shophou='", re.replace(this.shophou.Value), "',cardhead='", re.replace(this.cardhead.Value), "',shopisfig=", re.replace(this.shopisfig.SelectedValue), ",shopmopic='", re.replace(this.shopmopic.Text), "',flashfile='", re.replace(this.flash.Text), "',istotalpic=", this.istotalpic.Checked ? "1" : "0", 
            " where isnull(shopid,0)=" + base.AdminShopId
         }));
            base.Response.Write("<script language='javascript'>window.location.href='shop_config02.aspx';</script>");
            base.Response.End();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Session["Adminlogin"] == null)
            {
                base.Response.Write("<script language=javascript>window.top.location.href='../login.aspx';</script>");
                base.Response.End();
            }
            if (!base.IsPostBack)
            {
                this.Bind();
            }
        }

       

    }
}